/****************************************************************************
@FILENAME:	codec_uart.h
@FUNCTION:	decode/encode uart
@AUTHOR:	flege.zhang
@DATE:		2020.05.13
@COPYRIGHT(C) ZXW 2020
*****************************************************************************/

#ifndef _CODEC_UART__H_
#define _CODEC_UART__H_


#include "app_cfg.h"



#define AF_UART_HEADER													0xAA
#define AF_UART_TYPE_CMD												0xC0													
#define AF_UART_END														0x55


enum en_dec_uart_state
{
	EN_UART_HEADER 		= 0x00,
	EN_UART_TYPE,
	EN_UART_LENGTH,
	EN_UART_DATA,
	EN_UART_CHECKSUM,
	EN_UART_END,
};

typedef struct
{
	uint8_t header;
	uint8_t type;
	uint8_t length;
	uint8_t opcode;
	uint8_t group_index;
	uint8_t para[3];
	uint8_t checksum;
	uint8_t end;
}str_decoded_uart;


void decode_uart_init(uint32_t baudrate_index);
void decode_uart(uint8_t uart_data);

#endif
